package controlador;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import modelo.Usuario;

public class ControlJPAUsuario {

	EntityManagerFactory emf;
	EntityManager em;
	
	public ControlJPAUsuario() {
		emf = Persistence.createEntityManagerFactory("Anuncios");
		em = emf.createEntityManager();
		em.getTransaction().begin();
	}
	
	public boolean LoginControl(String username, String password){
		try{
			Usuario l = em.createNamedQuery("Usuario.Login", Usuario.class).setParameter("userName", username).setParameter("password", password).getSingleResult();
			
			if(l != null){
				return true;
			}
			return false;
		}catch(Exception e){
			
		}
		return false;
	}

}
